/*     */ package dm.jdbc.rowset;
/*     */ 
/*     */ import dm.jdbc.dbaccess.Const;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import java.io.CharArrayReader;
/*     */ import java.io.InputStream;
/*     */ import java.io.OutputStream;
/*     */ import java.io.Reader;
/*     */ import java.io.Serializable;
/*     */ import java.io.StringBufferInputStream;
/*     */ import java.io.Writer;
/*     */ import java.sql.Clob;
/*     */ import java.sql.SQLException;
/*     */ import java.util.ResourceBundle;
/*     */ 
/*     */ public class DmdbSerialClob implements Serializable, Cloneable, Clob
/*     */ {
/*     */   private char[] m_buffer;
/*     */   private long m_length;
/*     */   
/*     */   DmdbSerialClob(char[] buf)
/*     */   {
/*  23 */     if (buf != null) {
/*  24 */       this.m_length = buf.length;
/*     */     } else {
/*  26 */       this.m_length = 0L;
/*     */     }
/*  28 */     if (this.m_length <= 0L) {
/*  29 */       return;
/*     */     }
/*  31 */     this.m_buffer = new char[(int)this.m_length];
/*  32 */     System.arraycopy(buf, 0, this.m_buffer, 0, (int)this.m_length);
/*     */   }
/*     */   
/*     */   DmdbSerialClob(Clob clob) throws SQLException {
/*  36 */     if (clob == null) {
/*  37 */       return;
/*     */     }
/*  39 */     this.m_length = clob.length();
/*     */     
/*  41 */     if (this.m_length > 2147483647L) {
/*  42 */       throw new SQLException(Const.res.getString("error.dataTooLarge"));
/*     */     }
/*  44 */     this.m_buffer = new char[(int)this.m_length];
/*  45 */     String ret = clob.getSubString(1L, (int)this.m_length);
/*  46 */     ret.getChars(0, ret.length(), this.m_buffer, 0);
/*     */   }
/*     */   
/*     */   public long length() throws SQLException {
/*  50 */     return this.m_length;
/*     */   }
/*     */   
/*     */   public String getSubString(long pos, int length) throws SQLException {
/*  54 */     if ((pos < 1L) || (pos + length > this.m_length)) {
/*  55 */       DBError.throwSQLException(6057);
/*     */     }
/*  57 */     char[] dest = new char[length];
/*  58 */     System.arraycopy(this.m_buffer, (int)(pos - 1L), dest, 0, length);
/*     */     
/*  60 */     return new String(dest);
/*     */   }
/*     */   
/*     */   public Reader getCharacterStream() throws SQLException {
/*  64 */     return new CharArrayReader(this.m_buffer);
/*     */   }
/*     */   
/*     */   public InputStream getAsciiStream() throws SQLException {
/*  68 */     return new StringBufferInputStream(new String(this.m_buffer));
/*     */   }
/*     */   
/*     */   public long position(String searchstr, long start) throws SQLException {
/*  72 */     if ((searchstr == null) || (searchstr.length() == 0) || (start > this.m_length) || 
/*  73 */       (start < 1L)) {
/*  74 */       return -1L;
/*     */     }
/*  76 */     long posRet = -1L;
/*  77 */     int ptnsize = searchstr.length();
/*  78 */     for (int i = (int)(start - 1L); i < this.m_length;)
/*     */     {
/*  80 */       for (int j = 0; 
/*  81 */           j < ptnsize; j++) {
/*  82 */         if (this.m_buffer[i] != searchstr.charAt(j))
/*     */           break;
/*  84 */         i++;
/*     */       }
/*     */       
/*  87 */       if (j == ptnsize) {
/*  88 */         posRet = i + 1;
/*  89 */         break;
/*     */       }
/*  91 */       j = 0;
/*  92 */       i++;
/*     */     }
/*     */     
/*     */ 
/*  96 */     return posRet;
/*     */   }
/*     */   
/*     */   public long position(Clob searchstr, long start) throws SQLException {
/* 100 */     if (searchstr == null) {
/* 101 */       return -1L;
/*     */     }
/* 103 */     return position(searchstr.getSubString(0L, (int)searchstr.length()), 
/* 104 */       start);
/*     */   }
/*     */   
/*     */   public int setString(long pos, String str) throws SQLException {
/* 108 */     DBError.throwUnsupportedSQLException();
/*     */     
/* 110 */     return -1;
/*     */   }
/*     */   
/*     */   public int setString(long pos, String str, int offset, int len) throws SQLException
/*     */   {
/* 115 */     DBError.throwUnsupportedSQLException();
/*     */     
/* 117 */     return -1;
/*     */   }
/*     */   
/*     */   public OutputStream setAsciiStream(long pos) throws SQLException {
/* 121 */     DBError.throwUnsupportedSQLException();
/*     */     
/* 123 */     return null;
/*     */   }
/*     */   
/*     */   public Writer setCharacterStream(long pos) throws SQLException {
/* 127 */     DBError.throwUnsupportedSQLException();
/*     */     
/* 129 */     return null;
/*     */   }
/*     */   
/*     */   public void truncate(long len) throws SQLException
/*     */   {}
/*     */   
/*     */   public void free() throws SQLException
/*     */   {
/* 137 */     if ((this.m_buffer != null) || (this.m_length != 0L)) {
/* 138 */       this.m_buffer = null;
/* 139 */       this.m_length = 0L;
/*     */     }
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\rowset\DmdbSerialClob.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       0.7.1
 */